package hhh.app.presenter.ui.adapter;

import android.content.Context;
import android.widget.ImageView;

import com.squareup.picasso.Picasso;
import com.zhy.adapter.recyclerview.CommonAdapter;
import com.zhy.adapter.recyclerview.base.ViewHolder;

import java.util.List;

import hhh.app.R;
import hhh.app.common.Code;
import hhh.app.data.bean.Product;

/**
 * Created by Administrator on 2017/1/31 0031.
 */
public class ProductListAdapter extends CommonAdapter<Product> {

    public ProductListAdapter(Context context, int layoutId, List<Product> datas) {
        super(context, layoutId, datas);
    }

    @Override
    protected void convert(ViewHolder holder, Product p, int position) {
//        holder.setLabel(p.getName())
//                .setRating((float) p.getRating())
//                .setSpecial((float) p.getSpecial())
//                .setPrice((float) p.getPrice())
//                .setCount(20)
//                .setIv(Code.baseImageUrl+p.getImage());
        holder.setText(R.id.item_label,p.getName())
                .setText(R.id.item_price, String.valueOf(p.getPrice()))
                .setRating(R.id.item_rating, (float) p.getRating())
                .setText(R.id.item_special, String.valueOf(p.getSpecial()))
                .setText(R.id.item_sale_count,"20");

        Picasso.with(mContext)
                .load(Code.baseImageUrl+p.getImage())
                .into((ImageView) holder.getView(R.id.item_iv));

    }
}
